package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.GoodsAttribute;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QGoodsAttribute is a DSLite query type for GoodsAttribute
 * @see GoodsAttribute
 */
public class QGoodsAttribute extends QEntityBase<GoodsAttribute> {

    public static final QGoodsAttribute $ = new QGoodsAttribute("GOODS_ATTRIBUTE");

    public final StringColumn goodsId = varchar("GOODS_ID", 22).field("goodsId").notNull().build();

    public final StringColumn attributeId = varchar("ATTRIBUTE_ID", 22).field("attributeId").notNull().build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndexD = index("CONSTRAINT_INDEX_D").unique().column(goodsId).column(attributeId).build();

        public final Index constraintIndexD9 = index("CONSTRAINT_INDEX_D9").column(attributeId).build();

        public final Index constraintIndexD93 = index("CONSTRAINT_INDEX_D93").column(goodsId).build();

        public final Index primaryKeyD = index("PRIMARY_KEY_D").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintD93 = foreignKey(attributeId, "ATTRIBUTE", "ID");

        public final ForeignKey constraintD931 = foreignKey(goodsId, "GOODS", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoodsAttribute(String tableName) {
        super(GoodsAttribute.class, tableName);
    }

    @Override
    public GoodsAttribute newEntity() {
        return new GoodsAttribute();
    }

    @Override
    public Object getFieldValue(GoodsAttribute entity, String fieldName) {
        switch (fieldName) {
            case "goodsId":
                return entity.getGoodsId();
            case "attributeId":
                return entity.getAttributeId();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(GoodsAttribute entity, String fieldName, Object value) {
        switch (fieldName) {
            case "goodsId":
                entity.setGoodsId((java.lang.String) value);
                break;
            case "attributeId":
                entity.setAttributeId((java.lang.String) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

